package com.shenmazong.serverpagehelper.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shenmazong.serverpagehelper.mapper.ITbBookMapper;
import com.shenmazong.serverpagehelper.pojo.TbBook;
import com.shenmazong.serverpagehelper.pojo.TbPoetry;
import com.shenmazong.serverpagehelper.service.PageService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author 田不平
 * @project server-security
 * @date 2020/3/30 2:40 PM
 * http://www.shenmazong.com
 */
@Service
@Slf4j
public class PageServiceImpl implements PageService {

    @Autowired
    ITbBookMapper iTbBookMapper;

    @Override
    public IPage<TbBook> getListByAuthorId(Integer pageCurrent, Integer pageSize) {
        //QueryWrapper<TbBook> queryWrapper = new QueryWrapper<>();
        //queryWrapper.eq("authorid", authorId);

        Page<TbBook> page = new Page<>(pageCurrent, pageSize);
        IPage<TbBook> iPage = iTbBookMapper.selectPage(page, null);
        System.out.println("总页数:"+iPage.getPages());
        System.out.println("总记录数:"+iPage.getTotal());

        return iPage;
    }
}
